package com.aqie.easy.binarySearch;

/**
 * 852
 * A.length >= 3
 * 存在 0 < i < A.length - 1 使得A[0] < A[1] < ... A[i-1] < A[i] > A[i+1] > ... > A[A.length - 1]
 * 给定一个确定为山脉的数组，返回任何满足 A[0] < A[1] < ... A[i-1] < A[i] > A[i+1] > ... > A[A.length - 1] 的 i 的值。
 */
public class PeakIndexInMountainArray {
    public int peakIndexInMountainArray(int[] A) {
        int ans = 0;
        int num = 0;
        for (int i = 0; i < A.length; i++){
           if (num < A[i]){
               ans = i;
               num = A[i];
           }
        }
        return ans;
    }
}
